#include "gBar.h"

gBar::gBar()
{
	m_perc = 1.0f;
}

gBar::~gBar()
{

}

void gBar::initBar(char* a_back, char* a_bar, char* a_fore, V2DF a_pos, V2DF a_off)
{
	m_back.init(FRAMEWORKS_MEM_REG);
	m_back.initTexture(a_back,TEX_BL,a_pos,V2D_ONES,0);

	m_bar.init(FRAMEWORKS_MEM_REG);
	m_bar.initTexture(a_bar,TEX_BL,a_pos+a_off,V2D_ONES,0);

	m_fore.init(FRAMEWORKS_MEM_REG);
	m_fore.initTexture(a_fore,TEX_BL,a_pos,V2D_ONES,0);
}

void gBar::update()
{
	if(m_bar.refScl().y < 0.0f)
		m_bar.refScl().y = 0.0f;
	else
		m_bar.refScl().y = m_perc;

	m_back.update();
	m_bar.update();
	m_fore.update();
}

void gBar::draw()
{
	m_back.draw();
	m_bar.draw();
	m_fore.draw();
}